<template>
  <div>
    <MyHeader
      title="淘宝购物车"
      backgroundColor="black"
      color="#fff"
    >
    </MyHeader>

<!-- 内容区域 -->
 <div class="main">
    <!-- component动态切换内容 -->
       <component :is="comName"></component>
    </div>

    <MyTabBar :tabs="tabList" @changBar="changeFn"></MyTabBar>
  </div>
</template>

<script>
import MyHeader from "./components/MyHeader";
import MyTabBar from "./components/MyTabBar";

//页面
import MyGoodsList from "./views/MyGoodsList";
import MySearch from "./views/MySearch";
import UserInfo from "./views/UserInfo";

export default {
  data() {
    return {
       comName:'MyGoodsList',
        tabList: [
        {
          icon: "icon-shangpinliebiao",
          text: "商品列表",
          name: "MyGoodsList",
        },
        {
          icon: "icon-sousuo",
          text: "商品搜索",
          name: "MySearch",
        },
        {
          icon: "icon-user",
          text: "我的信息",
          name: "UserInfo",
        },
      ],
    };
  },
  //方法
  methods: {
     changeFn(index) {
        this.comName = this.tabList[index].name
      //   console.log(index);
      // console.log(this.comName);
     }
  },
  //过滤器
  filters: {},
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 组件名
  components: {
    MyHeader,
    MyTabBar,
    MyGoodsList,
    MySearch,
    UserInfo
  },
};
</script>

<style scoped>
.main{
   padding: 45px 0 50px 0;
}
</style>

